** REPLICATION DO FILE FOR
** Heinisch, R., Saxonberg, S., Werner, A., & Habersack, F. (2021). The effect of radical right fringe parties on main parties in Central and Eastern Europe: Empirical evidence from manifesto data. Party Politics, 27(1), 9-21. doi: 10.1177/1354068819863620
** Please direct questions to Annika Werner (annika.werner@anu.edu.au)
** Version: 02.06.2024


clear
set more off 

*** 1 Dataset Construction
*** 2 Analysis

***************
***************
** PREPARATION
***************
***************

clear
set more off
use MPDataset_MPDS2018a

***** Poland, starting 2001 (all three parties present) to 2007 (when PiS present but others not)
keep if country == 92
tab date
keep if date > 199709 & date < 201110
tab date
/* mainstream == 92436 (PiS); fringe == 92622 (SRP) & 92713 (LPR)*/
tab party
gen type = 3
replace type = 1 if party == 92436
replace type = 2 if party == 92622 | party == 92713
label var type partytype
label define partytype 1 "mainstream" 2 "fringe" 3 "other"
label val type partytype
tab type party 
keep party type date country per501-per706 

reshape wide per* country, i(party) j(date)

gen m_502_0105 = per502200509 - per502200109
gen m_601_0105 = per601200509 - per601200109
gen m_602_0105 = per602200509 - per602200109
gen m_603_0105 = per603200509 - per603200109
gen m_604_0105 = per604200509 - per604200109
gen m_605_0105 = per605200509 - per605200109
gen m_606_0105 = per606200509 - per606200109
gen m_607_0105 = per607200509 - per607200109
gen m_608_0105 = per608200509 - per608200109
gen m_705_0105 = per705200509 - per705200109
gen m_706_0105 = per706200509 - per706200109

gen m_502_0507 = per502200710 - per502200509
gen m_601_0507 = per601200710 - per601200509
gen m_602_0507 = per602200710 - per602200509
gen m_603_0507 = per603200710 - per603200509
gen m_604_0507 = per604200710 - per604200509
gen m_605_0507 = per605200710 - per605200509
gen m_606_0507 = per606200710 - per606200509
gen m_607_0507 = per607200710 - per607200509
gen m_608_0507 = per608200710 - per608200509
gen m_705_0507 = per705200710 - per705200509
gen m_706_0507 = per706200710 - per706200509


* generate one observation to summarize all 'other'
set obs 10
replace party = 1 in 10
label define CMPpartycode 1 "other", add
label val party CMPpartycode

drop per501* per503* per504* per505* per506* per507* per701* per702* per703* per704*
reshape long per502 per601 per602 per603 per604 per605 per606 per607 per608 per705 per706 ///
		, i(party) j(date)
drop if type == 3 & per502 == .
export excel using "Poland_fringe", firstrow(variables)	replace
* manually reshape data
clear
import excel "Poland_fringe_reformated.xls", sheet("stacked dataset") firstrow
save Poland_fringe, replace

		
***** Slovakia * start 2002 when SMER arrives (first fringe in next election, SNS in 2006)
clear
set more off
use MPDataset_MPDS2018a

keep if country == 96
tab date
keep if date > 199809

/* mainstream == 96423 (Smer); fringe == 92620 (OLaNo) & 92710 (SNS) & 96955 (Most-Hid)*/
tab party
gen type = 3
replace type = 1 if party == 96423
replace type = 2 if party == 96620 | party == 96710 | party == 96955
label var type partytype
label define partytype 1 "mainstream" 2 "fringe" 3 "other"
label val type partytype
tab type party 
keep party type date country per501-per706 

reshape wide per* country, i(party) j(date)

gen m_502_0206 = per502200606 - per502200209
gen m_601_0206 = per601200606 - per601200209
gen m_602_0206 = per602200606 - per602200209
gen m_603_0206 = per603200606 - per603200209
gen m_604_0206 = per604200606 - per604200209
gen m_605_0206 = per605200606 - per605200209
gen m_606_0206 = per606200606 - per606200209
gen m_607_0206 = per607200606 - per607200209
gen m_608_0206 = per608200606 - per608200209
gen m_705_0206 = per705200606 - per705200209
gen m_706_0206 = per706200606 - per706200209

gen m_502_0610 = per502201006 - per502200606
gen m_601_0610 = per601201006 - per601200606
gen m_602_0610 = per602201006 - per602200606
gen m_603_0610 = per603201006 - per603200606
gen m_604_0610 = per604201006 - per604200606
gen m_605_0610 = per605201006 - per605200606
gen m_606_0610 = per606201006 - per606200606
gen m_607_0610 = per607201006 - per607200606
gen m_608_0610 = per608201006 - per608200606
gen m_705_0610 = per705201006 - per705200606
gen m_706_0610 = per706201006 - per706200606

gen m_502_1012 = per502201203 - per502201006
gen m_601_1012 = per601201203 - per601201006
gen m_602_1012 = per602201203 - per602201006
gen m_603_1012 = per603201203 - per603201006
gen m_604_1012 = per604201203 - per604201006
gen m_605_1012 = per605201203 - per605201006
gen m_606_1012 = per606201203 - per606201006
gen m_607_1012 = per607201203 - per607201006
gen m_608_1012 = per608201203 - per608201006
gen m_705_1012 = per705201203 - per705201006
gen m_706_1012 = per706201203 - per706201006

* generate one observation to summarize all 'other'
set obs 14
replace party = 1 in 14
label define CMPpartycode 1 "other", add
label val party CMPpartycode

drop per501* per503* per504* per505* per506* per507* per701* per702* per703* per704*
reshape long per502 per601 per602 per603 per604 per605 per606 per607 per608 per705 per706 ///
		, i(party) j(date)
drop if type == 3 & per502 == .
export excel using "Slovakia_fringe", firstrow(variables) replace	
* manually reshape data
clear
import excel "Slovakia_fringe_reformated.xls", sheet("stacked dataset") firstrow
save Slovakia_fringe, replace

****** Romania * whole time frame but need to create mainstream parties
clear
set more off
use MPDataset_MPDS2018a
keep if country == 93

* align parties: 1 = social democrats, 2 = liberals (in 2012 liberals joined soc dems, 93031)
gen party2 = party
replace party2 = 1 if party == 93223 | party == 93001 | party == 93002 | party == 93031
replace party2 = 2 if party == 93430 | party == 93411 | party == 93041
drop party
rename party2 party

drop if party == 93223 | party == 93001 | party == 93002 | party == 93031
drop if party == 93430 | party == 93411 | party == 93041

/* mainstream == 1 (soc dems) & 2 (liberals); fringe == 93711 (PUNR) & 93712 (PRM) & 93981 (PP_DD)*/
tab party
gen type = 3
replace type = 1 if party == 1 | party == 2
replace type = 2 if party == 93711 | party == 93712 | party == 93981
label var type partytype
label define partytype 1 "mainstream" 2 "fringe" 3 "other"
label val type partytype
tab type 
keep party type date per501-per706 

reshape wide per* , i(party) j(date)

gen m_502_9092 = per502199209 - per502199005
gen m_601_9092 = per601199209 - per601199005
gen m_602_9092 = per602199209 - per602199005
gen m_603_9092 = per603199209 - per603199005
gen m_604_9092 = per604199209 - per604199005
gen m_605_9092 = per605199209 - per605199005
gen m_606_9092 = per606199209 - per606199005
gen m_607_9092 = per607199209 - per607199005
gen m_608_9092 = per608199209 - per608199005
gen m_705_9092 = per705199209 - per705199005
gen m_706_9092 = per706199209 - per706199005

gen m_502_9296 = per502199611 - per502199209
gen m_601_9296 = per601199611 - per601199209
gen m_602_9296 = per602199611 - per602199209
gen m_603_9296 = per603199611 - per603199209
gen m_604_9296 = per604199611 - per604199209
gen m_605_9296 = per605199611 - per605199209
gen m_606_9296 = per606199611 - per606199209
gen m_607_9296 = per607199611 - per607199209
gen m_608_9296 = per608199611 - per608199209
gen m_705_9296 = per705199611 - per705199209
gen m_706_9296 = per706199611 - per706199209

gen m_502_9600 = per502200011 - per502199611
gen m_601_9600 = per601200011 - per601199611
gen m_602_9600 = per602200011 - per602199611
gen m_603_9600 = per603200011 - per603199611
gen m_604_9600 = per604200011 - per604199611
gen m_605_9600 = per605200011 - per605199611
gen m_606_9600 = per606200011 - per606199611
gen m_607_9600 = per607200011 - per607199611
gen m_608_9600 = per608200011 - per608199611
gen m_705_9600 = per705200011 - per705199611
gen m_706_9600 = per706200011 - per706199611

gen m_502_0004 = per502200411 - per502200011
gen m_601_0004 = per601200411 - per601200011
gen m_602_0004 = per602200411 - per602200011
gen m_603_0004 = per603200411 - per603200011
gen m_604_0004 = per604200411 - per604200011
gen m_605_0004 = per605200411 - per605200011
gen m_606_0004 = per606200411 - per606200011
gen m_607_0004 = per607200411 - per607200011
gen m_608_0004 = per608200411 - per608200011
gen m_705_0004 = per705200411 - per705200011
gen m_706_0004 = per706200411 - per706200011

gen m_502_0408 = per502200811 - per502200411
gen m_601_0408 = per601200811 - per601200411
gen m_602_0408 = per602200811 - per602200411
gen m_603_0408 = per603200811 - per603200411
gen m_604_0408 = per604200811 - per604200411
gen m_605_0408 = per605200811 - per605200411
gen m_606_0408 = per606200811 - per606200411
gen m_607_0408 = per607200811 - per607200411
gen m_608_0408 = per608200811 - per608200411
gen m_705_0408 = per705200811 - per705200411
gen m_706_0408 = per706200811 - per706200411

gen m_502_0812 = per502201212 - per502200811
gen m_601_0812 = per601201212 - per601200811
gen m_602_0812 = per602201212 - per602200811
gen m_603_0812 = per603201212 - per603200811
gen m_604_0812 = per604201212 - per604200811
gen m_605_0812 = per605201212 - per605200811
gen m_606_0812 = per606201212 - per606200811
gen m_607_0812 = per607201212 - per607200811
gen m_608_0812 = per608201212 - per608200811
gen m_705_0812 = per705201212 - per705200811
gen m_706_0812 = per706201212 - per706200811
* generate one observation to summarize all 'other'
set obs 23
replace party = 3 in 23
label define CMPpartycode 3 "other", add
label val party CMPpartycode

drop per501* per503* per504* per505* per506* per507* per701* per702* per703* per704*
reshape long per502 per601 per602 per603 per604 per605 per606 per607 per608 per705 per706 ///
		, i(party) j(date)
		
gen country = "Romania"
drop if type == 3 & per502 == .
export excel using "Romania_fringe", firstrow(variables) replace	
* manually reshape data
clear
import excel "Romania_fringe_reformated.xls", sheet("stacked dataset") firstrow
save Romania_fringe, replace

append using Poland_fringe
append using Slovakia_fringe

drop if country == ""

save fringe_rom_pol_slo, replace


****** Hungary * start 2006 as Jobbik starts 2010
clear
set more off
use MPDataset_MPDS2018a
keep if country == 86
tab party
tab date 
drop if date < 200604

/* mainstream == 86081 (FiDeSz); fringe == 86710 (Jobbik)*/
gen type = 3
replace type = 1 if party == 86061
replace type = 2 if party == 86710 
label var type partytype
label define partytype 1 "mainstream" 2 "fringe" 3 "other"
label val type partytype
tab type date
keep party type date per501-per706 

reshape wide per* , i(party) j(date)

gen m_502_0610 = per502201004 - per502200604
gen m_601_0610 = per601201004 - per601200604
gen m_602_0610 = per602201004 - per602200604
gen m_603_0610 = per603201004 - per603200604
gen m_604_0610 = per604201004 - per604200604
gen m_605_0610 = per605201004 - per605200604
gen m_606_0610 = per606201004 - per606200604
gen m_607_0610 = per607201004 - per607200604
gen m_608_0610 = per608201004 - per608200604
gen m_705_0610 = per705201004 - per705200604
gen m_706_0610 = per706201004 - per706200604

gen m_502_1014 = per502201404 - per502201004
gen m_601_1014 = per601201404 - per601201004
gen m_602_1014 = per602201404 - per602201004
gen m_603_1014 = per603201404 - per603201004
gen m_604_1014 = per604201404 - per604201004
gen m_605_1014 = per605201404 - per605201004
gen m_606_1014 = per606201404 - per606201004
gen m_607_1014 = per607201404 - per607201004
gen m_608_1014 = per608201404 - per608201004
gen m_705_1014 = per705201404 - per705201004
gen m_706_1014 = per706201404 - per706201004

* generate one observation to summarize all 'other'
set obs 11
replace party = 3 in 11
label define CMPpartycode 3 "other", add
label val party CMPpartycode

drop per501* per503* per504* per505* per506* per507* per701* per702* per703* per704*
reshape long per502 per601 per602 per603 per604 per605 per606 per607 per608 per705 per706 ///
		, i(party) j(date)
		
gen country = "Hungary"
drop if type == 3 & per502 == .
export excel using "Hungary_fringe", firstrow(variables) replace	
* manually reshape data
clear
import excel "Hungary_fringe_reformated.xls", sheet("stacked dataset") firstrow
save Hungary_fringe, replace

****** Czech Republic, first fringe in 1992 -> start 1990
clear
set more off
use MPDataset_MPDS2018a
keep if country == 82
tab date
tab party
replace party = 82720 if party == 82952
/* mainstream == 82413 (ODS); fringe == 82430 (ANO) & 82720 (Usvit) & 82710 (SPR)*/
gen type = 3
replace type = 1 if party == 82413
replace type = 2 if party == 82430 | party == 82720 | party == 82710
label var type partytype
label define partytype 1 "mainstream" 2 "fringe" 3 "other"
label val type partytype
tab type date
keep party type date per501-per706 

reshape wide per* , i(party) j(date)

gen m_502_9092 = per502199206 - per502199006
gen m_601_9092 = per601199206 - per601199006
gen m_602_9092 = per602199206 - per602199006
gen m_603_9092 = per603199206 - per603199006
gen m_604_9092 = per604199206 - per604199006
gen m_605_9092 = per605199206 - per605199006
gen m_606_9092 = per606199206 - per606199006
gen m_607_9092 = per607199206 - per607199006
gen m_608_9092 = per608199206 - per608199006
gen m_705_9092 = per705199206 - per705199006
gen m_706_9092 = per706199206 - per706199006

gen m_502_9296 = per502199605 - per502199206
gen m_601_9296 = per601199605 - per601199206
gen m_602_9296 = per602199605 - per602199206
gen m_603_9296 = per603199605 - per603199206
gen m_604_9296 = per604199605 - per604199206
gen m_605_9296 = per605199605 - per605199206
gen m_606_9296 = per606199605 - per606199206
gen m_607_9296 = per607199605 - per607199206
gen m_608_9296 = per608199605 - per608199206
gen m_705_9296 = per705199605 - per705199206
gen m_706_9296 = per706199605 - per706199206

gen m_502_9698 = per502199806 - per502199605
gen m_601_9698 = per601199806 - per601199605
gen m_602_9698 = per602199806 - per602199605
gen m_603_9698 = per603199806 - per603199605
gen m_604_9698 = per604199806 - per604199605
gen m_605_9698 = per605199806 - per605199605
gen m_606_9698 = per606199806 - per606199605
gen m_607_9698 = per607199806 - per607199605
gen m_608_9698 = per608199806 - per608199605
gen m_705_9698 = per705199806 - per705199605
gen m_706_9698 = per706199806 - per706199605

gen m_502_9802 = per502200206 - per502199806
gen m_601_9802 = per601200206 - per601199806
gen m_602_9802 = per602200206 - per602199806
gen m_603_9802 = per603200206 - per603199806
gen m_604_9802 = per604200206 - per604199806
gen m_605_9802 = per605200206 - per605199806
gen m_606_9802 = per606200206 - per606199806
gen m_607_9802 = per607200206 - per607199806
gen m_608_9802 = per608200206 - per608199806
gen m_705_9802 = per705200206 - per705199806
gen m_706_9802 = per706200206 - per706199806

gen m_502_0206 = per502200606 - per502200206
gen m_601_0206 = per601200606 - per601200206
gen m_602_0206 = per602200606 - per602200206
gen m_603_0206 = per603200606 - per603200206
gen m_604_0206 = per604200606 - per604200206
gen m_605_0206 = per605200606 - per605200206
gen m_606_0206 = per606200606 - per606200206
gen m_607_0206 = per607200606 - per607200206
gen m_608_0206 = per608200606 - per608200206
gen m_705_0206 = per705200606 - per705200206
gen m_706_0206 = per706200606 - per706200206

gen m_502_0610 = per502201005 - per502200606
gen m_601_0610 = per601201005 - per601200606
gen m_602_0610 = per602201005 - per602200606
gen m_603_0610 = per603201005 - per603200606
gen m_604_0610 = per604201005 - per604200606
gen m_605_0610 = per605201005 - per605200606
gen m_606_0610 = per606201005 - per606200606
gen m_607_0610 = per607201005 - per607200606
gen m_608_0610 = per608201005 - per608200606
gen m_705_0610 = per705201005 - per705200606
gen m_706_0610 = per706201005 - per706200606

gen m_502_1013 = per502201310 - per502201005
gen m_601_1013 = per601201310 - per601201005
gen m_602_1013 = per602201310 - per602201005
gen m_603_1013 = per603201310 - per603201005
gen m_604_1013 = per604201310 - per604201005
gen m_605_1013 = per605201310 - per605201005
gen m_606_1013 = per606201310 - per606201005
gen m_607_1013 = per607201310 - per607201005
gen m_608_1013 = per608201310 - per608201005
gen m_705_1013 = per705201310 - per705201005
gen m_706_1013 = per706201310 - per706201005

* generate one observation to summarize all 'other'
set obs 22
replace party = 3 in 22
label define CMPpartycode 3 "other", add
label val party CMPpartycode

drop per501* per503* per504* per505* per506* per507* per701* per702* per703* per704*
reshape long per502 per601 per602 per603 per604 per605 per606 per607 per608 per705 per706 ///
		, i(party) j(date)
		
gen country = "Czech Republic"
drop if type == 3 & per502 == .
export excel using "CZ_fringe", firstrow(variables) replace	
* manually reshape data
clear
import excel "CZ_fringe_reformated.xls", sheet("stacked dataset") firstrow
save CZ_fringe, replace

****** Bulgaria, from 2005 (first time Ataka), in 2017 Ataka in a coalition -> combine
clear
set more off
use MPDataset_MPDS2018a
keep if country == 80
replace party = 80710 if party == 80071
drop if date < 200506
tab date
/* mainstream == 80510 (GERB); fringe == 80710 (ATAKA)*/
tab party
gen type = 3
replace type = 1 if party == 80510
replace type = 2 if party == 80710 | party == 80640
label var type partytype
label define partytype 1 "mainstream" 2 "fringe" 3 "other"
label val type partytype
tab type 
keep party type date per501-per706 

reshape wide per* , i(party) j(date)

gen m_502_0509 = per502200907 - per502200506
gen m_601_0509 = per601200907 - per601200506
gen m_602_0509 = per602200907 - per602200506
gen m_603_0509 = per603200907 - per603200506
gen m_604_0509 = per604200907 - per604200506
gen m_605_0509 = per605200907 - per605200506
gen m_606_0509 = per606200907 - per606200506
gen m_607_0509 = per607200907 - per607200506
gen m_608_0509 = per608200907 - per608200506
gen m_705_0509 = per705200907 - per705200506
gen m_706_0509 = per706200907 - per706200506

gen m_502_0913 = per502201305 - per502200907
gen m_601_0913 = per601201305 - per601200907
gen m_602_0913 = per602201305 - per602200907
gen m_603_0913 = per603201305 - per603200907
gen m_604_0913 = per604201305 - per604200907
gen m_605_0913 = per605201305 - per605200907
gen m_606_0913 = per606201305 - per606200907
gen m_607_0913 = per607201305 - per607200907
gen m_608_0913 = per608201305 - per608200907
gen m_705_0913 = per705201305 - per705200907
gen m_706_0913 = per706201305 - per706200907

gen m_502_1314 = per502201410 - per502201305
gen m_601_1314 = per601201410 - per601201305
gen m_602_1314 = per602201410 - per602201305
gen m_603_1314 = per603201410 - per603201305
gen m_604_1314 = per604201410 - per604201305
gen m_605_1314 = per605201410 - per605201305
gen m_606_1314 = per606201410 - per606201305
gen m_607_1314 = per607201410 - per607201305
gen m_608_1314 = per608201410 - per608201305
gen m_705_1314 = per705201410 - per705201305
gen m_706_1314 = per706201410 - per706201305

gen m_502_1417 = per502201703 - per502201410
gen m_601_1417 = per601201703 - per601201410
gen m_602_1417 = per602201703 - per602201410
gen m_603_1417 = per603201703 - per603201410
gen m_604_1417 = per604201703 - per604201410
gen m_605_1417 = per605201703 - per605201410
gen m_606_1417 = per606201703 - per606201410
gen m_607_1417 = per607201703 - per607201410
gen m_608_1417 = per608201703 - per608201410
gen m_705_1417 = per705201703 - per705201410
gen m_706_1417 = per706201703 - per706201410
* generate one observation to summarize all 'other'
set obs 17
replace party = 3 in 17
label define CMPpartycode 3 "other", add
label val party CMPpartycode

drop per501* per503* per504* per505* per506* per507* per701* per702* per703* per704*
reshape long per502 per601 per602 per603 per604 per605 per606 per607 per608 per705 per706 ///
		, i(party) j(date)
		
gen country = "Bulgaria"
drop if type == 3 & per502 == .
export excel using "Bulgaria_fringe", firstrow(variables) replace	
* manually reshape data
clear
import excel "Bulgaria_fringe_reformated.xls", sheet("stacked dataset") firstrow
save Bulgaria_fringe, replace


** append them all
clear
use fringe_rom_pol_slo
append using Hungary_fringe
append using CZ_fringe
append using Bulgaria_fringe

save fringe_all





****************
****************
** DATA ANALYSIS
****************
****************

use fringe_all.dta
set scheme plottig

replace country = "Slovakia" if country == "slovakia"
replace country = "Poland" if country == "poland"

* exclude VV and Most-Hid from earlier analysis
drop if fringe == 82952 | fringe == 96955

*** Correlations
estpost corr movemainstream fringetzero 
esttab
estpost corr movemainstream fringetone 
esttab 
estpost corr movemainstream moveother
esttab

bysort country: pwcorr movemainstream fringetzero, sig o 
bysort country: pwcorr movemainstream fringetone , sig o
bysort country: pwcorr movemainstream moveother , sig o
bysort country: estpost corr fringetzero fringetone movemainstream moveother,  matrix listwise
esttab, unstack not

*** Scatter Plots
 
label var movemainstream "main party"

twoway (lfitci movemainstream fringetzero) (scatter movemainstream fringetzero, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(country, total note(""))  ///
	xtitle("Category salience in fringe party at t0") ///
	ytitle("Change salience in main party from t0 to t1")
graph export FringeMain_t0.eps, as(eps) replace

twoway (lfitci movemainstream fringetone) (scatter movemainstream fringetone, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(country, total note(""))  ///
	xtitle("Category salience in fringe party at t1") ///
	ytitle("Change salience in main party from t0 to t1")
graph export FringeMain_t1.eps, as(eps) replace

label var category cat
label define cat 502 "Culture" 601 "Nationalism positive" 602 "Nationalism negative" 603 "Traditional Morality positive" 604 "Traditional Morality negative" 605 "Law & order" 606 "Civic mindedness" 607 "Multiculture positive" 608 "Multiculture negative" 705 "Minority groups positive" 706 "Non-economic groups positive"
label val category cat

twoway (lfitci movemainstream fringetzero) (scatter movemainstream fringetzero, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(category, total note(""))  ///
	xtitle("Category salience in fringe party at t0") ///
	ytitle("Change salience in main party from t0 to t1")
graph export FringeMain_t0_cats.eps, as(eps) replace

twoway (lfitci movemainstream fringetone) (scatter movemainstream fringetone, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(category, total note(""))  ///
	xtitle("Category salience in fringe party at t1") ///
	ytitle("Change salience in main party from t0 to t1")
graph export FringeMain_t1_cats.eps, as(eps) replace

*** Regression
reg movemainstream fringetzero fringetone, cluster(country)
estimates store m1, title(Model 1)
reg movemainstream fringetzero fringetone moveother, cluster(country)
estimates store m2, title(Model 2)
reg movemainstream fringetzero fringetone moveother timeone, cluster(country)
estimates store m3, title(Model 3)

estout m1 m2 m3, cells(b(star fmt(3)) se(par fmt(2)))   ///
   legend label varlabels(_cons constant)               ///
   stats(r2 df_r bic, fmt(3 0 1) label(R-sqr dfres BIC))

reg movemainstream fringetzero fringetone i.category , cluster(country)
estimates store m4, title(Model 4)
reg movemainstream c.fringetzero##i.category fringetone , cluster(country)
estimates store m5, title(Model 5)
reg movemainstream fringetzero c.fringetone##i.category , cluster(country)
estimates store m6, title(Model 6)

estout m4 m5 m6, cells(b(star fmt(3)) se(par fmt(2)))   ///
   legend label varlabels(_cons constant)               ///
   stats(r2 df_r bic, fmt(3 0 1) label(R-sqr dfres BIC)) 
 
encode country, gen(cnt)   
reg movemainstream fringetzero fringetone moveother timeone ib4.cnt, cluster(country)  



** Do the paired categories have intra-pair influence?
clear
import excel "allcountries,paircats_final.xls", sheet("Sheet1") firstrow
* exclude VV and Most-Hid from earlier analysis
drop if fringe == 82952 | fringe == 96955

label var category cat
label define cat 502 "Culture" 601 "Nationalism positive" 602 "Nationalism negative" 603 "Traditional Morality positive" 604 "Traditional Morality negative" 605 "Law & order" 606 "Civic mindedness" 607 "Multiculture positive" 608 "Multiculture negative" 705 "Minority groups positive" 706 "Non-economic groups positive"
label val category cat

estpost corr movemainstream_2 fringetzero 
esttab
estpost corr movemainstream_2 fringetone 
esttab

bysort country: pwcorr movemainstream_2 fringetzero, sig o 
bysort country: pwcorr movemainstream_2 fringetone , sig o

label var movemainstream_2 "main party"

twoway (lfitci movemainstream_2 fringetzero) (scatter movemainstream_2 fringetzero, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(country, total note(""))  ///
	xtitle("Category salience in fringe party at t0") ///
	ytitle("Change salience in opposite category," "main party from t0 to t1")
graph export FringeMain_2_t0.eps, as(eps) replace

twoway (lfitci movemainstream_2 fringetone) (scatter movemainstream_2 fringetone, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(country, total note(""))  ///
	xtitle("Category salience in fringe party at t1") ///
	ytitle("Change salience in opposite category," "in main party from t0 to t1")
graph export FringeMain_2_t1.eps, as(eps) replace

twoway (lfitci movemainstream_2 fringetzero) (scatter movemainstream_2 fringetzero, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(category, total note(""))  ///
	xtitle("Category salience in fringe party at t0") ///
	ytitle("Change salience in opposite category," "in main party from t0 to t1")
graph export FringeMain_2_t0_cats.eps, as(eps) replace

twoway (lfitci movemainstream_2 fringetone) (scatter movemainstream_2 fringetone, sort), ///
	by(, legend(position(5)))  legend(rows(1)) by(category, total note(""))  ///
	xtitle("Category salience in fringe party at t1") ///
	ytitle("Change salience in opposite category," "in main party from t0 to t1")
graph export FringeMain_2_t1_cats.eps, as(eps) replace

*** Correlating saliencies at the same election
clear
use "MPDataset_MPDS2018a.dta"
keep if country == 92 | country == 96 | country == 93 | country == 86 | country == 82 | country == 80

replace party = 82720 if party == 82952
replace party = 93223 if  party == 93001 | party == 93002 | party == 93031
replace party = 93430 if  party == 93411 | party == 93041

gen type = 3
replace type = 1 if party == 80510 | party == 82413 | party == 86061 | party == 93223 | party == 93430 
replace type = 1 if party == 96423 | party == 92436
replace type = 2 if party == 80710 | party == 80640 | party == 82430 | party == 82720 | party == 82710
replace type = 2 if party == 86710 | party == 93711 | party == 93712 | party == 93981
replace type = 2 if party == 96620 | party == 96710 |  party == 92622 | party == 92713
label var type partytype
label define partytype 1 "main" 2 "fringe" 3 "other"
label val type partytype

drop if type == 3

tab edate
bysort type: sum pervote absseat
by type: tab parfam

keep party type date per502 per601-per608 per705 per706
reshape long per , i(party date) 
sort date party per

keep if type == 1
save mainstream_sal
keep if type == 2
save fringe_sal
append using mainstream_sal
save mainstream_fringe_sal

drop if party_2 == "svk: Bridge"
/*per == mainstream; _2 == fringe*/
gen country=substr(party, 1, 3)
replace country = "Bulgaria" if country == "bgr"
replace country = "Czech Republic" if country == "cze"
replace country = "Hungary" if country == "hun"
replace country = "Poland" if country == "pol"
replace country = "Romania" if country == "rou"
replace country = "Slovakia" if country == "svk"
tab country

label var _j cat
label define cat 502 "Culture" 601 "Nationalism positive" 602 "Nationalism negative" 603 "Traditional Morality positive" 604 "Traditional Morality negative" 605 "Law & order" 606 "Civic mindedness" 607 "Multiculture positive" 608 "Multiculture negative" 705 "Minority groups positive" 706 "Non-economic groups positive"
label val _j cat

pwcorr per per_2, sig o 
bysort country: pwcorr per per_2, sig o 
bysort _j: pwcorr per per_2, sig o 

twoway (lfitci per per_2) (scatter per per_2, sort), ///
	  legend(rows(1) position(5) label(1 "fitted values") label(2 "saliencies") label(3 ""))  /// 
	  xtitle(Fringe party salience) ytitle(Main party salience) ///
	  aspectratio(1) xlabel(0(5)20) ylabel(0(5)20) 
graph export Salience_all.eps, as(eps) replace

twoway (lfitci per per_2) (scatter per per_2, sort), ///
	  by(country, total note("")) legend(rows(1) label(1 "") label(2 "fitted values") label(3 "main party")) ///  
	  xtitle(Fringe party salience) ytitle(Main party salience) ///
	   by(, legend(position(5)))
graph export Salience_country.eps, as(eps) replace

twoway (lfitci per per_2) (scatter per per_2, sort), ///
	  by(_j, total note("")) legend(rows(1) label(1 "") label(2 "fitted values") label(3 "main party")) ///  
	  xtitle(Fringe party salience) ytitle(Main party salience) ///
	   by(, legend(position(5)))
graph export Salience_categories.eps, as(eps) replace


*** Correlating saliencies, lagged election, fringe at t0, mainstream at t1
clear
use mainstream_fringe_sal_lag
drop if party_2 == "svk: Bridge"
/*per == mainstream; _2 == fringe*/
gen country=substr(party, 1, 3)
replace country = "Bulgaria" if country == "bgr"
replace country = "Czech Republic" if country == "cze"
replace country = "Hungary" if country == "hun"
replace country = "Poland" if country == "pol"
replace country = "Romania" if country == "rou"
replace country = "Slovakia" if country == "svk"
tab country

label var _j cat
label define cat 502 "Culture" 601 "Nationalism positive" 602 "Nationalism negative" 603 "Traditional Morality positive" 604 "Traditional Morality negative" 605 "Law & order" 606 "Civic mindedness" 607 "Multiculture positive" 608 "Multiculture negative" 705 "Minority groups positive" 706 "Non-economic groups positive"
label val _j cat

pwcorr per per_2, sig o 
bysort country: pwcorr per per_2, sig o 
bysort _j: pwcorr per per_2, sig o 

twoway (lfitci per per_2) (scatter per per_2, sort), ///
	  legend(rows(1) position(5) label(1 "fitted values") label(2 "saliencies") label(3 ""))  /// 
	  xtitle(Fringe party salience at t0) ytitle(Main party salience at t1) 
graph export Salience_all_lag.eps, as(eps) replace

twoway (lfitci per per_2) (scatter per per_2, sort), ///
	  by(country, total note("")) legend(rows(1) label(1 "") label(2 "fitted values") label(3 "main party")) ///  
	  xtitle(Fringe party salience at t0) ytitle(Main party salience at t1) ///
	   by(, legend(position(5)))
graph export Salience_country_lag.eps, as(eps) replace

twoway (lfitci per per_2) (scatter per per_2, sort), ///
	  by(_j, total note("")) legend(rows(1) label(1 "") label(2 "fitted values") label(3 "main party")) ///  
	  xtitle(Fringe party salience at t0) ytitle(Main party salience at t1) ///
	   by(, legend(position(5)))
graph export Salience_categories_lag.eps, as(eps) replace


